//
//  ViewController.m
//  gitKraken_test
//
//  Created by MTCC on 2017/6/5.
//  Copyright © 2017年 CC. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()
@property (weak, nonatomic) IBOutlet UISlider *slider;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.slider.minimumValue = 0;
    self.slider.maximumValue = 1;
    self.slider.value = 0.3;
    self.slider.minimumTrackTintColor = [UIColor redColor];
    self.slider.maximumTrackTintColor = [UIColor yellowColor];
    self.slider.thumbTintColor = [UIColor purpleColor];
    self.slider.continuous = YES; // 默认就是Yes,No的话,则每次滑块停止移动后才触发事件
    [self.slider addTarget:self action:@selector(sliderChange:) forControlEvents:UIControlEventValueChanged];
}

- (void)sliderChange:(id)sender {
    if ([sender isKindOfClass:[UISlider class]]) {
        UISlider *slide = sender;
        CGFloat value = slide.value;
        self.view.backgroundColor = [UIColor colorWithRed:value green:value blue:value alpha:value];
    }
    
}

@end
